home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 1.6 KB | 78 lines | [TEXT/CWIE] |
- // MasterPointer.cp
-
- #ifndef MasterPointer_h
- #include "MasterPointer.h"
- #endif
- #ifndef MemoryFullError_h
- #include "MemoryFullError.h"
- #endif
-
- void MasterPointer::ThrowAllocationError( OSErr error, void *pointer )
- {
- if ( error == memFullErr )
- throw MemoryFullError();
-
- if ( error != noErr )
- throw MemoryError( error );
-
- if ( pointer == 0 )
- throw MemoryFullError();
- }
-
- void *MasterPointer::operator new( uint32 pointerSize )
- {
- Assert( pointerSize == sizeof( void * ) );
- void *result = NewEmptyHandle();
-
- ThrowAllocationError( MemError(), result );
-
- return result;
- }
-
- void *MasterPointer::operator new( uint32 pointerSize, uint32 blockSize )
- {
- Assert( pointerSize == sizeof( void * ) );
- void *result = NewHandle( blockSize );
-
- ThrowAllocationError( MemError(), result );
-
- return result;
- }
-
- void *MasterPointer::operator new( uint32 pointerSize, SystemHeap )
- {
- Assert( pointerSize == sizeof( void * ) );
- void *result = NewEmptyHandleSys();
-
- ThrowAllocationError( MemError(), result );
-
- return result;
- }
-
- void *MasterPointer::operator new( uint32 pointerSize, uint32 blockSize, SystemHeap )
- {
- Assert( pointerSize == sizeof( void * ) );
- void *result = NewHandleSys( blockSize );
-
- ThrowAllocationError( MemError(), result );
-
- return result;
- }
-
- void *MasterPointer::operator new( uint32 pointerSize, uint32 blockSize, Temporary )
- {
- Assert( pointerSize == sizeof( void * ) );
- OSErr error;
- void *result = TempNewHandle( blockSize, &error );
-
- ThrowAllocationError( error, result );
-
- return result;
- }
-
- void MasterPointer::operator delete( void *handle )
- {
- DisposeHandle( static_cast<::Handle>( handle ) );
- }
-
-